<div class="container-fluid" ng-switch="isError">

  <!-- ng-if="isError" -->
  <div ng-switch-when="true">
    <div class="alert alert-danger">
      {{err_message}}
    </div>
  </div>

  <div ng-switch-when="false" ng-switch="isLoaded">
    <div ng-switch-when="false">
      <p>Loading. . .</p>
    </div>
    <div class="row" ng-switch-when="true">
      <div class="col-sm-12 col-md-12 main">
        <h1 ng-if="!create" class="page-header">Edit Account</h1>
        <h1 ng-if="create" class="page-header">Create Account</h1>
        <form class="form-horizontal" role="form">
          <div class="form-group">
          <label for="AccountName" class="col-sm-2 control-label" tooltip-placement="right" tooltip="Name the account however you would like. (Up to 50 characters).">
            Name
          </label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="AccountName" placeholder="Name" ng-model="account.name" maxlength="50"
              tooltip-placement="left" tooltip="Name the account however you would like. (Up to 50 characters).">
            </div>
          </div>
          <div class="form-group">
            <label for="Type" class="col-sm-2 control-label" tooltip-placement="right" tooltip="The type of account, for example AWS (default).">
               Type
            </label>
            <div class="col-sm-10">
              <select id="AccountType" ng-model="account.account_type" class="form-control">
                  <option ng-repeat="option in config.account_types" value="{{ option }}">{{ option }}</option>
              </select>
            </div>
          </div>
          <div class="form-group">
            <label for="AccountIdentifier" class="col-sm-2 control-label" tooltip-placement="right" tooltip="{{ config.identifier_tool_tips[account.account_type]}}">{{ config.identifier_labels[account.account_type] }}</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="AccountIdentifier" ng-model="account.identifier" maxlength="256"
              tooltip-placement="left" tooltip="{{ config.identifier_tool_tips[account.account_type]}}">
            </div>
          </div>
          <div ng-repeat="custom_field in config.fields[account.account_type]" class="form-group">
            <label for="{{ custom_field.name }}" class="col-sm-2 control-label" tooltip-placement="right" tooltip="{{ custom_field.tool_tip }}">{{ custom_field.label }}</label>
            <div class="col-sm-10">
              <input ng-if="!custom_field.password &amp;&amp; custom_field.allowed_values==null" type="text" class="form-control" id="{{ custom_field.name }}" ng-model="account.custom_field_values[custom_field.name]" ng-disabled="!custom_field.editable", maxlength="256"
              tooltip-placement="left" tooltip="{{ custom_field.tool_tip}}">
              <input ng-if="custom_field.password" type="password" class="form-control" id="{{ custom_field.name }}" ng-model="account.custom_field_values[custom_field.name]" ng-disabled="!custom_field.editable", maxlength="256"
              tooltip-placement="left" tooltip="{{ custom_field.tool_tip}}">
              <select ng-if="custom_field.allowed_values!=null" id="{{ custom_field.name }}" ng-model="account.custom_field_values[custom_field.name]" class="form-control" ng-disabled="!custom_field.editable"
                      tooltip-placement="left" tooltip="{{ custom_field.tool_tip}}">
                  <option ng-repeat="option in custom_field.allowed_values" value="{{ option }}">{{ option }}</option>
              </select>
            </div>
          </div>
          <div class="form-group">
            <label for="AccountNotes" class="col-sm-2 control-label" tooltip-placement="right" tooltip="Any account notes can go here. (Up to 256 characters).">Notes</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="AccountNotes" placeholder="Notes" ng-model="account.notes" maxlength="256"
              tooltip-placement="left" tooltip="Any account notes can go here. (Up to 256 characters).">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
              <div class="checkbox">
                <label>
                  <input type="checkbox" ng-model="account.active"
                    tooltip-placement="right" tooltip="This tells security monkey to interrogate this account for changes on a recurring schedule">
                    <p tooltip-placement="left" tooltip="This tells security monkey to interrogate this account for changes on a recurring schedule">Active <i><u>?</u>- (Should be scanned by security monkey.)</i></p>
                </label>
              </div>
              <div class="checkbox">
                <label>
                  <input type="checkbox" ng-model="account.third_party"
                  tooltip-placement="right" tooltip="Use this option to tell security monkey about a friendly third party account.  Third party accounts will never be interrogated by security monkey.">
                  <p tooltip-placement="left" tooltip="Use this option to tell security monkey about a friendly third party account.  Third party accounts will never be interrogated by security monkey."> Third Party <u>?</u></p>
                </label>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
              <button type="submit" class="btn btn-primary" ng-click="saveAccount()">Save</button>
              <button ng-if="!create" type="submit" class="btn btn-danger" ng-click="deleteAccount()">Delete</button>
            </div>
          </div>
          <hr />
          <h3 ng-if="create">Due to an open <a href="https://github.com/Netflix/security_monkey/issues/54">issue</a>. You must restart the scheduler on the scheduler instance after adding a new account.</h3>
          <pre ng-if="create" class="code">$ sudo supervisorctl
supervisor&gt; status
securitymonkeyscheduler          RUNNING    pid 19199, uptime 0:00:05
supervisor&gt; restart securitymonkeyscheduler
securitymonkeyscheduler: stopped
securitymonkeyscheduler: started
supervisor&gt;
          </pre>

        </form>
        </div>
      </div>
    </div>
  </div>
